﻿using NB.MGJ.FrameWork;
using NB.MGJ.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Service
{

    /// <summary>
    /// 系统PV与UV服务类
    /// </summary>
    public static class Sys_PV_UV_Service
    {
        /// <summary>
        /// 数据连接
        /// </summary>
        private static BaseRepository _baseRepository
        {
            get
            {
                return new BaseRepository();
            }
        }

        //private string _Ip { get; set; }
        //public Sys_PV_UV_Service SetIp(string _ip)
        //{
        //    if (string.IsNullOrWhiteSpace(_ip)) { throw new ArgumentNullException(_ip); }
        //    _Ip = _ip;
        //    return this;
        //}

        /// <summary>
        /// 访问量添加
        /// </summary>
        public static void PV_UV_Add(string _ip, string _pagename)
        {
            Task.Run(() =>
            {
                try
                {
                    _baseRepository.Insert<Sys_Pv_Uv>(new Sys_Pv_Uv
                    {
                        Ip = _ip,
                        PageName = _pagename,
                        ViewTime = DateTime.Now
                    });
                }
                catch { }

            });
        }
    }
}
